﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using MYA_WPF.Model;
using MYA_WPF.Utils;

namespace MYA_WPF.View
{
    /// <summary>
    /// Logique d'interaction pour Contact.xaml
    /// </summary>
    public partial class Contact : Page
    {
        public List<MYA_WPF.Model.Personne> personnes;

        public MYA_WPF.Utils.ContactDetail contactDetail;

        public Contact()
        {
            InitializeComponent();
            using (ManageYourAppointmentEntities dbcontext = new ManageYourAppointmentEntities())
            {
                personnes = dbcontext.Personnes.ToList<MYA_WPF.Model.Personne>();
                Binding b = new Binding();
                b.Source = personnes;
                this.listContact.SetBinding(DataContextProperty, b);
            }
        }

        private void listContact_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
        {
            int contactID = ((Personne)this.listContact.SelectedValue).Personne_Contact;

            contactDetail =  DataManager.getContactDetailByIdPersonne(contactID);

            this.nomDisplay.Text = contactDetail.Nom;
            this.prenomDisplay.Text = contactDetail.Prenom;
            this.dateNaissanceDisplay.Text = contactDetail.DateNaissance.ToShortDateString();
            this.adressedisplay.Text = contactDetail.Adresse;
            this.telephoneDisplay.Text = contactDetail.Telephone;
            this.emailDisplay.Text = contactDetail.Email;

        }

    }
}
